/**
 * 角色列表
 *
 * @author liuxiaotang
 */
define(["app", "comm/pager/PagerControl", "js/services/MessageBox", "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "MessageBox", "MuseService"];

    function controller ($scope, $state, $modal, MessageBox, MuseService) {
        //初始化查询对象
        app.regsiterCacheData($scope, $state);
        $scope.queryObj = $scope.queryObj || {};

        //获取列表
        $scope.getObjList = function () {
            MuseService.post("admin/adminauthres/list.json").success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.dataForTheTree = [];
                        var resultList = JSON.parse(data.data);
                        var tempList = [];
                        for (var x in resultList) {
                            var temp = {
                                "name": x,
                                "children": resultList[x]
                            };
                            tempList.push(temp);
                            $scope.expandedNodes.push(temp)
                        }

                        $scope.dataForTheTree = tempList;
                        console.log(tempList)
                    } else {
                        MessageBox.notify('获取信息失败：' + data.message);
                    }
                });
        };

        $scope.getObjList();

        //编辑
        $scope.edit = function () {
            $state.go('adminauthresEdit');
        };

        $scope.treeOptions = {
            nodeChildren: "children",
            dirSelectable: false,
            injectClasses: {
                ul: "a1",//根目录
                li: "a2",//根节点
                liSelected: "a7",//根节点（选中）
                iExpanded: "a3",//根节点图标（被展开）
                iCollapsed: "a4",//根节点图标（被收起）
                iLeaf: "a5",//底层节点图标
                label: "a6",//节点文字
                labelSelected: "a8"//节点文字（选中）
            }
        };
    }

    controller.$inject = deps;
    app.lazy.controller("AdminAuthResListController", controller);
});
